package com.angel.provider.health.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.angel.core.Constants;
import com.angel.core.base.BaseProviderImpl;
import com.angel.dao.health.BuzCompanyMapper;
import com.angel.health.BuzCompany;
import com.angel.provider.health.BuzCompanyProvider;

@Service
public class BuzCompanyProviderImpl extends BaseProviderImpl<BuzCompany> implements BuzCompanyProvider{
	
	@Autowired
	BuzCompanyMapper companyMapper;

	public int save(BuzCompany buzCompany) {
		Date date = new Date();
		buzCompany.setCreateTime(date);
		buzCompany.setUpdateTime(date);
		int i =companyMapper.insert(buzCompany);
		int idLen = buzCompany.getId().toString().length();
		String code = Constants.COMPANY_CODE;
		String _code = code.substring(0, code.length() - idLen)+buzCompany.getId();
		BuzCompany company = new BuzCompany();
		company.setId(buzCompany.getId());
		company.setCode(_code);
		companyMapper.updateByPrimaryKeySelective(company);
		return i;
	}

	//查询所有公司
	public List<BuzCompany> findAllCompany() {
		return companyMapper.findAllCompany();
	}

	
}
